package com.jeesite.modules.wx.entity;

import com.jeesite.modules.common.ErrorEnum;

import java.io.Serializable;

/**
 * 标准接口出参<p>
 *
 * @author Junjie Xu
 * @Description:success表示返回是否成功,data是业务返回对象,是个泛型类型,<br/> 不同接口需要传入相对应的类型, errorCode表示错误码，errorMessage是错误描述
 * <pre>
 *  public class Response<T> {
 *
 * 		private boolean success;
 *
 * 		private T data;
 *
 * 		private String errorCode;
 *
 * 		private String errorMessage;
 *
 * 		...
 * 	}
 * </pre>
 * @date 2015-12-28
 */
public class Response<T> implements Serializable {

    private static final long serialVersionUID = -7783475488658605915L;

    public Response() {
        this(false);
    }

    public Response(boolean success) {
        this(success, null);
    }

    public Response(ErrorEnum errorEnum) {
        this.setSuccess(false);
        this.setErrorCode(errorEnum.getErrorCode());
        this.setErrorMessage(errorEnum.getErrorMsg());
    }

    public Response(boolean success, T data) {
        this.setSuccess(success);
        this.data = data;
    }

    public Response(T data) {
        this(true, data);
    }

    /**
     * 是否成功 <br/>
     * true:成功 false:失败
     */
    private boolean success = false;
    /**
     * 返回数据
     */
    private T data;
    /**
     * 错误码
     */
    private String errorCode;
    /**
     * 错误描述
     */
    private String errorMessage;

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public String getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(String errorCode) {
        this.errorCode = errorCode;
    }

    public String getErrorMessage() {
        return errorMessage;
    }

    public void setErrorMessage(String errorMessage) {
        this.errorMessage = errorMessage;
    }
    

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}